package guda.house.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import guda.house.dal.dao.SuiteOutUserRelDAO;
import guda.house.dal.dataobject.SuiteOutUserRelDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SuiteOutUserRelDAOImpl extends BaseDAO implements SuiteOutUserRelDAO {

    @Override
	public Long insert(SuiteOutUserRelDO suiteOutUserRel) {
	      try {
                return (Long) getSqlMapperW().insert("suite_out_user_rel.insert",suiteOutUserRel);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public SuiteOutUserRelDO getSuiteOutUserRelById(Long relId) {
	    return (SuiteOutUserRelDO)getSqlMapClientTemplate().queryForObject("suite_out_user_rel.getSuiteOutUserRelById", relId);
	}

    @Override
	public boolean delSuiteOutUserRelById(Long relId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("suite_out_user_rel.delSuiteOutUserRelById",relId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<SuiteOutUserRelDO> getSuiteOutUserRelByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("suite_out_user_rel.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long relId) {
	    try {
            getSqlMapperW().update("suite_out_user_rel.cleanAutoIncrement",relId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<SuiteOutUserRelDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("suite_out_user_rel.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("suite_out_user_rel.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(SuiteOutUserRelDO suiteOutUserRel) {
        try {
            getSqlMapperW().update("suite_out_user_rel.updateByIdSelective",suiteOutUserRel);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void delSuiteOutUser(Long suiteId, String userId) {
        Map m = new HashMap();
        m.put("suiteId",suiteId);
        m.put("userId",userId);

        try {
            getSqlMapperW().delete("suite_out_user_rel.delSuiteOutUser",m);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public List<SuiteOutUserRelDO> getByOutUserId(String outUserId) {
        return getSqlMapClientTemplate().queryForList("suite_out_user_rel.getByOutUserId", outUserId);
    }

}

